<?php
# Inclusion des  classes de gestion
include_once "../../../class/sys/session.class.php";
$mySession = Session::getInstance();
if($mySession->getConnect()) {
	
	if( isset($_POST['id'])                    &&   
	    isset($_POST['nameObject'])            &&   
	    isset($_POST['descriptionObject'])     &&
		isset($_POST['stateObject'])           &&
		isset($_POST['categorieObject'])         

	) {

		
				// Fichier de conf
				require('../../../conf/database.conf.php');
				require('../../../conf/module.conf.php');
				// Drivers de connexion a la bdd
				require('../../../class/sys/database.class.php');
				
				
				include_once "../../../class/app/object.class.php";
				include_once "../../../class/app/person.class.php";
				
				function stro_replace($search, $replace, $subject)
				{
					return strtr( $subject, array_combine($search, $replace) );
				}
				
				
				$objet = new Object();

				

				$search = array("'");
				$replace = array("\'");
				
				$nameObject = $_POST['nameObject'];
				$decribObject = $_POST['descriptionObject'];

				
				$nameObject   = stro_replace($search, $replace, $nameObject);
				$decribObject = stro_replace($search, $replace, $decribObject);
				
				
								
				$objet->initialisation($_POST['id'], $nameObject, $decribObject,'', '', $_POST['categorieObject'], $_POST['stateObject'], '', '');
				
			
				$p_personne = $mySession->getPersonneSerialize();
				
				
				if($objet->update()) {
					$p_personne->chargerMonCoffre();
					$mySession->setPersonne($p_personne);
					echo "1";
				} else {
					echo "0";
				}
				
	

	} else {
		print ("<script language = \"JavaScript\">");
		print ("location.href = './';");
		print ("</script>");
	}
} else {
	print ("<script language = \"JavaScript\">");
	print ("location.href = './';");
	print ("</script>");
}
?>